Skip to content

fetch api: add support for downloading raw response #4917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jul 11, 2025

I need to make an authenticated request to the media repo, and expect to get a binary file back. AFAICT there is no easy way to do that right now.

@richvdh richvdh requested a review from a team as a code owner July 11, 2025 14:44
@richvdh richvdh added the T-Task Tasks for the team like planning label Jul 11, 2025
@richvdh richvdh requested review from dbkr and t3chguy July 11, 2025 14:44
@richvdh richvdh added the T-Task Tasks for the team like planning label Jul 11, 2025
richvdh added 2 commits July 13, 2025 21:14
... to make it easier to find the docs from methods that use it.
I need to make an authenticated request to the media repo, and expect to get a
binary file back. AFAICT there is no easy way to do that right now.
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading the types correctly, could the same not be achieved using onlyData=false json=false and adding a blob method to TypedResponse given res already sports this method it just isn't exposed in the interface.

@richvdh
Copy link
Member Author

richvdh commented Jul 16, 2025

If I'm reading the types correctly, could the same not be achieved using onlyData=false json=false and adding a blob method to TypedResponse given res already sports this method it just isn't exposed in the interface.

Yes, but onlyData is currently only supported at the level of the entire FetchHttpApi, so to do that we'd either have to instantiate a whole other FetchHttpApi instance with onlyData=false (in which case it would probably be easier just to call fetch directly) , or add it to IHttpOpts (which doesn't seem inherently better than adding IHttpOpts.rawResponseBody).

@richvdh richvdh requested a review from t3chguy July 16, 2025 19:58
Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay but ResponseType does not consider rawResponseBody so the types will only be right if onlyData=true or undefined, which does not match your comment which says rawResponseBody inhibits the behaviour of onlyData - as with rawResponseBody=true & onlyData=false (or json=false frankly) you would have a return type of TypedResponse (or string in the json=false) case

The types for rawResponseBody also do not inhibit you from entering this edge case, where they could/should.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants